package com.yuye.cloud.common.feign.fallback;

import com.yuye.cloud.common.vo.DictionaryVO;
import com.yuye.cloud.common.dto.DictionaryDTO;
import com.yuye.cloud.common.feign.DictionaryService;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;

import java.util.*;

/**
 * userService降级工场
 *
 * @author xgf
 */
@Slf4j
public class DictionaryServiceFallbackFactory implements FallbackFactory<DictionaryService> {
    @Override
    public DictionaryService create(Throwable throwable) {
        return new DictionaryService() {

			@Override
			public Map<String, List<DictionaryDTO>> findDictionaryByKeyList(DictionaryVO dictionaryVO) {
				 log.error("通过数据字典 typeKeys 查询数据字典异常:{}", dictionaryVO, throwable);
	             return new HashMap<>();
			}

			@Override
			public List<DictionaryDTO> findDictionaryByKey(String typeFlag) {
				 log.error("通过数据字典 查询唯一 typeKey 查询数据字典异常:{}", typeFlag, throwable);
	             return new ArrayList<DictionaryDTO>();
			}

			@Override
			public Optional<DictionaryDTO> findDictionaryByKey(String typeFlag, String dictKey) {
				log.error("通过数据字典 查询唯一 typeKey 查询数据字典异常:{}", typeFlag, throwable);
	             return Optional.ofNullable(null);
			}};
    }
}
